if exists(select name from sysobjects where name = 'sp_TinGetByTinChaId')
	drop proc sp_TinGetByTinChaId
go
/*
	Created by: Phuoc NH
	Created on: 25/01/2013 (dd/mm/yyyy)
	Description: lay tin theo id tin cha
	--
	File:$sql-scripts/Proc.sp_TinGetByTinChaId.sql
*/

create proc sp_TinGetByTinChaId
@Tin_cha_id int
as
begin
	SET DATEFORMAT dmy
	declare @top int
	--lay select top cua tin cha
	set @top=(select select_top from tbl_Tin where Tin_id=@Tin_cha_id)
	if(@top<0)
		begin
			select Tin_id, Tieu_de, Tom_tat, Noi_dung, Anh_nho, Anh_to, Ngay_tao, url from tbl_Tin where Tin_cha_id=@Tin_cha_id and Status=1
		end
	else
		begin
			select top (@top) Tin_id, Tieu_de, Tom_tat, Noi_dung, Anh_nho, Anh_to, Ngay_tao, url from tbl_Tin where Tin_cha_id=@Tin_cha_id and Status=1
		end
end
go

